package com.hbisedm.interninfosys.intern.controller;

import com.alibaba.fastjson.JSON;
import com.hbisedm.interninfosys.commonutils.R;
import com.hbisedm.interninfosys.intern.entity.Menu;
import com.hbisedm.interninfosys.intern.entity.Meta;
import com.hbisedm.interninfosys.intern.service.IMenuService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Sam
 * @since 2020-12-02
 */
@RestController
@RequestMapping("/intern/menu")
public class MenuController {
    @Autowired
    private IMenuService menuService;
    /**
     * 添加菜单
     */
    @PostMapping("/add")
    public R addMenu(@RequestBody Menu menu){
        System.out.println(menu);
        Meta meta = new Meta();
        BeanUtils.copyProperties(menu,meta);
        System.out.println(meta);
//        String s = JSON.toJSONString(meta);
//        menu.setMeta(s);
        boolean save = menuService.save(menu);
        return R.ok().data("status", save);
    }



}
